home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / Translation.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  12.0 KB  |  328 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Translation.h
  3.  
  4.      Contains:    Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1991-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __TRANSLATION__
  18. #define __TRANSLATION__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __FILES__
  24. #include <Files.h>
  25. #endif
  26. #ifndef __COMPONENTS__
  27. #include <Components.h>
  28. #endif
  29. #ifndef __TRANSLATIONEXTENSIONS__
  30. #include <TranslationExtensions.h>
  31. #endif
  32.  
  33.  
  34.  
  35. #if PRAGMA_ONCE
  36. #pragma once
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_STRUCT_ALIGN
  48.     #pragma options align=mac68k
  49. #elif PRAGMA_STRUCT_PACKPUSH
  50.     #pragma pack(push, 2)
  51. #elif PRAGMA_STRUCT_PACK
  52.     #pragma pack(2)
  53. #endif
  54.  
  55. /* enumerated types on how a document can be opened*/
  56. typedef short                             DocOpenMethod;
  57.  
  58. enum {
  59.     domCannot                    = 0,
  60.     domNative                    = 1,
  61.     domTranslateFirst            = 2,
  62.     domWildcard                    = 3
  63. };
  64.  
  65. /* 0L terminated array of OSTypes, or FileTypes*/
  66. typedef OSType                             TypesBlock[64];
  67. typedef OSType *                        TypesBlockPtr;
  68. /* Progress dialog resource ID*/
  69.  
  70. enum {
  71.     kTranslationScrapProgressDialogID = -16555
  72. };
  73.  
  74. /* block of data that describes how to translate*/
  75.  
  76. struct FileTranslationSpec {
  77.     OSType                             componentSignature;
  78.     const void *                    translationSystemInfo;
  79.     FileTypeSpec                     src;
  80.     FileTypeSpec                     dst;
  81. };
  82. typedef struct FileTranslationSpec        FileTranslationSpec;
  83. typedef FileTranslationSpec *            FileTranslationSpecArrayPtr;
  84. typedef FileTranslationSpecArrayPtr *    FileTranslationSpecArrayHandle;
  85.  
  86. /*****************************************************************************************
  87. *   GetFileTypesThatAppCanNativelyOpen
  88. *  This routine returns a list of all FileTypes that an application can open by itself
  89. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  90. *             appSignature        signature (creator) of application
  91. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  92. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  93. */
  94. EXTERN_API( OSErr )
  95. GetFileTypesThatAppCanNativelyOpen (short                 appVRefNumHint,
  96.                                  OSType                 appSignature,
  97.                                  FileType *                nativeTypes)                        TWOWORDINLINE(0x701C, 0xABFC);
  98.  
  99. /*****************************************************************************************
  100. *  ExtendFileTypeList
  101. *  This routine makes a new list of file types that can be translated into a type in the given list
  102. *  Used by StandardFile
  103. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  104. *             numberOriginalTypes        number of file types in orgTypeList
  105. *              extendedTypeList        pointer to a buffer to be filled with file types
  106. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  107. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  108. *             numberExtendedTypes        number of file types put in extendedTypeList
  109. */
  110. EXTERN_API( OSErr )
  111. ExtendFileTypeList                (const FileType *        originalTypeList,
  112.                                  short                     numberOriginalTypes,
  113.                                  FileType *                extendedTypeList,
  114.                                  short *                numberExtendedTypes)                TWOWORDINLINE(0x7009, 0xABFC);
  115.  
  116.  
  117. /*****************************************************************************************
  118. *  This routine checks if a file can be opened by a particular application.
  119. *  If so, it returns if it needs to be translated first, and if so then how.
  120. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  121. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  122. *  Enter:    targetDocument        document to check if it can be opened
  123. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  124. *             appSignature        signature (creator) of application to open doc
  125. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  126. *             onlyNative            whether to consider if document can be translated before opening
  127. *             howToOpen            pointer to buffer in which to put how the document can be opened
  128. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  129. *  Exit:    howToOpen            whether file needs to be translated to be read
  130. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  131. *             returns                noErr, noPrefAppErr
  132. */
  133. EXTERN_API( OSErr )
  134. CanDocBeOpened                    (const FSSpec *            targetDocument,
  135.                                  short                     appVRefNumHint,
  136.                                  OSType                 appSignature,
  137.                                  const FileType *        nativeTypes,
  138.                                  Boolean                 onlyNative,
  139.                                  DocOpenMethod *        howToOpen,
  140.                                  FileTranslationSpec *    howToTranslate)                        TWOWORDINLINE(0x701E, 0xABFC);
  141.  
  142.  
  143. /*****************************************************************************************
  144. *  GetFileTranslationPaths
  145. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  146. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  147. *  Enter:    srcDoc            source file or NULL for all matches
  148. *             dstDoc            destination FileType or 0 for all matches
  149. *             maxResultCount
  150. *             resultBuffer
  151. *  Exit:    number of paths
  152. */
  153. EXTERN_API( short )
  154. GetFileTranslationPaths            (FSSpec *                srcDocument,
  155.                                  FileType                 dstDocType,
  156.                                  unsigned short         maxResultCount,
  157.                                  FileTranslationSpecArrayPtr  resultBuffer)                    TWOWORDINLINE(0x7038, 0xABFC);
  158.  
  159. /*****************************************************************************************
  160. *  GetPathFromTranslationDialog
  161. *  This routine, with a given document, application, and a passed typelist will display the
  162. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  163. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  164. *  The routine returns the translation path information.
  165. *  Enter:    theDocument            FSSpec to document to open
  166. *             theApplication        FSSpec to application to open document
  167. *             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  168. *                                 you would like the documented translated to.  Order most perferred
  169. *                                 to least.
  170. *  Exit:    howToOpen            Translation method needed to open document
  171. *             howToTranslate        Translation specification
  172. *             returns                Any errors that might occur.
  173. */
  174. EXTERN_API( OSErr )
  175. GetPathFromTranslationDialog    (const FSSpec *            theDocument,
  176.                                  const FSSpec *            theApplication,
  177.                                  TypesBlockPtr             typeList,
  178.                                  DocOpenMethod *        howToOpen,
  179.                                  FileTranslationSpec *    howToTranslate)                        TWOWORDINLINE(0x7037, 0xABFC);
  180.  
  181.  
  182. /*****************************************************************************************
  183. *   TranslateFile
  184. *  This routine reads a file of one format and writes it to another file in another format. 
  185. *  The information on how to translated is generated by the routine CanDocBeOpened.
  186. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  187. *  The destination file must not exist.  It is created by this routine.  
  188. *  Enter:    sourceDocument            input file to translate
  189. *             destinationDocument        output file of translation
  190. *             howToTranslate            pointer to info on how to translate
  191. *  Exit:    returns                    noErr, badTranslationSpecErr 
  192. */
  193. EXTERN_API( OSErr )
  194. TranslateFile                    (const FSSpec *            sourceDocument,
  195.                                  const FSSpec *            destinationDocument,
  196.                                  const FileTranslationSpec * howToTranslate)                TWOWORDINLINE(0x700C, 0xABFC);
  197.  
  198. /*****************************************************************************************
  199. *   GetDocumentKindString
  200. *  This routine returns the string the Finder should show for the "kind" of a document
  201. *  in the GetInfo window and in the kind column of a list view.  
  202. *  Enter:    docVRefNum        The volume containing the document
  203. *             docType            The catInfo.fdType of the document
  204. *             docCreator        The catInfo.fdCreator of the document
  205. *             kindString        pointer to where to return the string
  206. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  207. *             returns            noErr, or afpItemNoFound if kind could not be determined
  208. */
  209. EXTERN_API( OSErr )
  210. GetDocumentKindString            (short                     docVRefNum,
  211.                                  OSType                 docType,
  212.                                  OSType                 docCreator,
  213.                                  Str63                     kindString)                            TWOWORDINLINE(0x7016, 0xABFC);
  214.  
  215. /*****************************************************************************************
  216. *  GetTranslationExtensionName
  217. *  This routine returns the translation system name from a specified TranslationSpec
  218. *  Enter:    translationMethod    The translation path to get the translation name from
  219. *  Exit:    extensionName        The name of the translation system
  220. *             returns                Any errors that might occur
  221. */
  222. EXTERN_API( OSErr )
  223. GetTranslationExtensionName        (const FileTranslationSpec * translationMethod,
  224.                                  Str31                     extensionName)                        TWOWORDINLINE(0x7036, 0xABFC);
  225.  
  226.  
  227. /*****************************************************************************************
  228. *  GetScrapDataProcPtr
  229. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  230. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  231. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  232. *  with a list all the formats that you have available to be translated, and the length of each.
  233. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  234. *  the formats that 'fmts' list said was available.
  235. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  236. *             dataH                    Handle in which to put the requested data
  237. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  238. *             
  239. *  Exit:    dataH                    Handle is resized and filled with data in requested format
  240. */
  241. typedef CALLBACK_API( OSErr , GetScrapDataProcPtr )(ScrapType requestedFormat, Handle dataH, void *srcDataGetterRefCon);
  242. typedef STACK_UPP_TYPE(GetScrapDataProcPtr)                     GetScrapDataUPP;
  243. enum { uppGetScrapDataProcInfo = 0x00000FE0 };                     /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  244. #define NewGetScrapDataProc(userRoutine)                         (GetScrapDataUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture())
  245. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon)  CALL_THREE_PARAMETER_UPP((userRoutine), uppGetScrapDataProcInfo, (requestedFormat), (dataH), (srcDataGetterRefCon))
  246.  
  247. typedef GetScrapDataUPP                 GetScrapData;
  248. /*****************************************************************************************
  249. *  TranslateScrap
  250. *  This routine resizes the destination handle and fills it with data of the requested format.
  251. *  The data is generated by translated one or more source formats of data supplied by
  252. *  the procedure srcDataGetter.  
  253. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  254. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  255. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  256. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  257. *             destinationFormat            Format of data desired
  258. *             destinationData                Handle in which to store translated data
  259. *             
  260. *  Exit:    dstData                        Handle is resized and filled with data in requested format
  261. */
  262. EXTERN_API( OSErr )
  263. TranslateScrap                    (GetScrapDataUPP         sourceDataGetter,
  264.                                  void *                    sourceDataGetterRefCon,
  265.                                  ScrapType                 destinationFormat,
  266.                                  Handle                 destinationData,
  267.                                  short                     progressDialogID)                    TWOWORDINLINE(0x700E, 0xABFC);
  268.  
  269.  
  270.  
  271.  
  272. #if PRAGMA_STRUCT_ALIGN
  273.     #pragma options align=reset
  274. #elif PRAGMA_STRUCT_PACKPUSH
  275.     #pragma pack(pop)
  276. #elif PRAGMA_STRUCT_PACK
  277.     #pragma pack()
  278. #endif
  279.  
  280. #ifdef PRAGMA_IMPORT_OFF
  281. #pragma import off
  282. #elif PRAGMA_IMPORT
  283. #pragma import reset
  284. #endif
  285.  
  286. #ifdef __cplusplus
  287. }
  288. #endif
  289.  
  290. #endif /* __TRANSLATION__ */
  291.  
  292.